package com.ftx.service.article.impl;

import com.ftx.domain.alias.PageCondition;
import com.ftx.domain.query.ArticleQuery;
import com.ftx.domain.vo.ArticleVO;
import com.ftx.domain.vo.PageVO;
import com.ftx.manager.article.ArticleManager;
import com.ftx.service.article.ArticleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by fengtingxin on 2019/6/23.
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Resource
    private ArticleManager articleManager;


    @Override
    public PageVO<ArticleVO> pageByCondition(PageCondition pageCondition, ArticleQuery query) {
        PageVO<ArticleVO> pageVO = new PageVO<ArticleVO>();
        List<ArticleVO> articleVOList = articleManager.pageByCondition(pageCondition,query);
        pageVO.setCurrentPage(pageCondition.getCurrentPage());
        pageVO.setPagesize(pageCondition.getPageSize());
        pageVO.setTotalCount(pageCondition.getTotalCount());
        pageVO.setTotalPage(pageCondition.getTotalPage());
        //手动构造的paginatedList，没有算总页数
//        pageVO.setTotalPage();
        pageVO.setEntity(articleVOList);
        return pageVO;
    }
}
